const http = require('http')
const fs = require('fs')
const mime = require('mime')

const server = http.createServer((req, res) => {
  let urlString = req.url
  let type = mime.getType(urlString.split('.')[urlString.split('.').length - 1])
  fs.readFile(`.${urlString}`, (err, content) => {
    res.writeHead(200, {
      "Content-Type": type
    })
    res.end(content)
  })
})

server.listen(5000, () => {
  console.log('5000端口的服务以启动');
})